package com.weblog.weblogapi.controller;

import com.weblog.weblogapi.dao.pojo.User;
import com.weblog.weblogapi.service.UserService;
import com.weblog.weblogapi.vo.Result;
import com.weblog.weblogapi.vo.params.RegisterParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("user")
public class UserController {
    @Autowired
    private UserService userService;
    @PostMapping
    public Result aa(){return Result.success("kkkk");}
    //发送短信
    @PostMapping("sendMsg")
    public Result sendMsg(@RequestBody RegisterParam registerParam){
        return userService.sendMsg(registerParam);
    }
    //注册
    @PostMapping("register")
    public Result register(@RequestBody RegisterParam registerParam  ){return userService.register(registerParam);}
    //密码登录
    @PostMapping("login")
    public Result login(@RequestBody RegisterParam registerParam ){return userService.login(registerParam);}
    //短信登录
    @PostMapping("msgLogin")
    public Result msgLogin(@RequestBody RegisterParam registerParam ){return userService.msgLogin(registerParam);}
    //找回密码
    @PostMapping("findPassword")
    public Result findPassword(@RequestBody RegisterParam registerParam){return userService.findPassword(registerParam);}
    //修改个人信息
    @PostMapping("updateUser")
    public Result updateUser(@RequestBody User user){return userService.updateUser(user);}
    //更换头像
    @PostMapping("updateAvatar")
    public Result updateAvatar(@RequestBody User user){return userService.updateAvatar(user);}
    //查找登录用户信息
    @GetMapping("currentUser")
    public Result currentUser(@RequestHeader("token") String token){
        return userService.findUserByToken(token);
    }
}
